package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.handing.domain.AlgsEthicalReview;
import com.ruoyi.handing.service.IAlgsEthicalReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.AlgsNewExperimentMapper;
import com.ruoyi.system.domain.AlgsNewExperiment;
import com.ruoyi.system.service.IAlgsNewExperimentService;

import javax.annotation.Resource;

/**
 * 申请新实验Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-16
 */
@Service
public class AlgsNewExperimentServiceImpl implements IAlgsNewExperimentService 
{
    @Autowired
    private AlgsNewExperimentMapper algsNewExperimentMapper;
    @Resource
    private IAlgsEthicalReviewService algsEthicalReview1;

    /**
     * 查询申请新实验
     * 
     * @param newExperimentId 申请新实验主键
     * @return 申请新实验
     */
    @Override
    public AlgsNewExperiment selectAlgsNewExperimentByNewExperimentId(Long newExperimentId)
    {
        return algsNewExperimentMapper.selectAlgsNewExperimentByNewExperimentId(newExperimentId);
    }

    /**
     * 查询申请新实验列表
     * 
     * @param algsNewExperiment 申请新实验
     * @return 申请新实验
     */
    @Override
    public List<AlgsNewExperiment> selectAlgsNewExperimentList(AlgsNewExperiment algsNewExperiment)
    {
        return algsNewExperimentMapper.selectAlgsNewExperimentList(algsNewExperiment);
    }

    /**
     * 新增申请新实验
     * 
     * @param algsNewExperiment 申请新实验
     * @return 结果
     */
    @Override
    public int insertAlgsNewExperiment(AlgsNewExperiment algsNewExperiment)
    {
        Long newExperimentId = algsNewExperiment.getNewExperimentId();
        String newExperimentName = algsNewExperiment.getNewExperimentName();
        AlgsEthicalReview algsEthicalReview = new AlgsEthicalReview();
//        algsEthicalReview.setEthicalReviewBy1(newExperimentId);

        algsEthicalReview.setEthicalReviewBy3("审核中");
        algsEthicalReview.setEthicalReviewBy2(newExperimentName);
        algsEthicalReview1.insertAlgsEthicalReview(algsEthicalReview);
        return algsNewExperimentMapper.insertAlgsNewExperiment(algsNewExperiment);
    }

    /**
     * 修改申请新实验
     * 
     * @param algsNewExperiment 申请新实验
     * @return 结果
     */
    @Override
    public int updateAlgsNewExperiment(AlgsNewExperiment algsNewExperiment)
    {
        return algsNewExperimentMapper.updateAlgsNewExperiment(algsNewExperiment);
    }

    /**
     * 批量删除申请新实验
     * 
     * @param newExperimentIds 需要删除的申请新实验主键
     * @return 结果
     */
    @Override
    public int deleteAlgsNewExperimentByNewExperimentIds(Long[] newExperimentIds)
    {
        return algsNewExperimentMapper.deleteAlgsNewExperimentByNewExperimentIds(newExperimentIds);
    }

    /**
     * 删除申请新实验信息
     * 
     * @param newExperimentId 申请新实验主键
     * @return 结果
     */
    @Override
    public int deleteAlgsNewExperimentByNewExperimentId(Long newExperimentId)
    {
        return algsNewExperimentMapper.deleteAlgsNewExperimentByNewExperimentId(newExperimentId);
    }
}
